		<!--{eval $attach_uploadify_id=$topic_textarea_id.$attach_uploadify_type.($attach_uploadify_topic[tid]>0?"_".$attach_uploadify_topic[tid]:"");}-->
		<!--{eval $attach_img_siz=$attach_img_siz?$attach_img_siz:32;}-->
		<!--{eval $attach_fz_siz=min(max(1,(int)$this->Config['attach_size_limit']),51200)*1024;}-->
		<!--{eval $topic_textarea_id=$topic_textarea_id?$topic_textarea_id:'i_already'.{$h_key};}-->
		<!--{eval $topic_textarea_empty_val=isset($topic_textarea_empty_val)?$topic_textarea_empty_val:'分享文件';}-->
		<!--{eval $attach_uploadify_queue_size_limit=min(max(1,(int)$this->Config[attach_files_limit]),50);}-->
		<!--{eval $attach_item=isset($this->item)?$this->item:'';}-->
		<!--{eval $attach_itemid=isset($this->item_id)?$this->item_id:0;}-->
		<success></success>

		<script type="text/javascript">
		
		var __ATTACH_IDS__ = {};
		
		$(document).ready(function(){			
			var upfilename = '';
			$('#publisher_file_attach{$attach_uploadify_id}').uploadify({
				'uploader'  : '{conf site_url}/images/uploadify/uploadify.swf?id={$attach_uploadify_id}&random=' + Math.random(),
			    'script'    : '{echo urlencode({conf site_url} . "/ajax.php?mod=uploadattach&code=attach&uninitmember=1&type=flash&aitem={$attach_item}&aitemid={$attach_itemid}")}',
			    'cancelImg' : '{conf site_url}/images/uploadify/cancel.png',
			    'buttonImg'	: '{conf site_url}/images/uploadify/addatta.gif',
			    'width'		: 111,
			    'height'	: 17,
			    'multi'		: true,
			    'auto'      : true,
			    'sizeLimit' : {$attach_fz_siz},
			    'fileExt'	: '*.rar;*.zip;*.txt;*.doc;*.xls;*.pdf;*.ppt;*.docx;*.xlsx;*.pptx',
			    'fileDesc'	: '*.rar;*.zip;*.txt;*.doc;*.xls;*.pdf;*.ppt;*.docx;*.xlsx;*.pptx',
			    'queueID'	: 'uploadifyQueueDivAttach{$attach_uploadify_id}',
			    'wmode'		: 'transparent',
			    'fileDataName'	 : 'topic',
			    'queueSizeLimit' : {$attach_uploadify_queue_size_limit},
			    'simUploadLimit' : 1,
			    'scriptData'	 : {
			    	{if $attach_uploadify_topic_uid}
			    	'topic_uid'  : '{$attach_uploadify_topic_uid}',
			    	{/if}
			    	'cookie_auth': '{echo urlencode(jsg_getcookie("auth"))}'
			    },
			    'onSelect'		 : function(event, ID, fileObj) {
			    },
			    'onSelectOnce'	 : function (event, data) {
			    	attachUploadifySelectOnce{$attach_uploadify_id}();			    	
			    },
			    'onProgress'     : function(event, ID, fileObj, data) {
			        return false;
			    },
			    'onComplete'	 : function(event, ID, fileObj, response, data) {
			    	eval('var r = ' + response + ';');
					if (r.done) {					
						var rv = r.retval;
						if ( rv.id > 0 && rv.src.length > 0 ) {
							attachUploadifyComplete{$attach_uploadify_id}(rv.id, rv.src, fileObj.name);
							upfilename = fileObj.name;
						}
					}
					else
					{
						if(r.msg)
						{
							if(r.msg=='forbidden'){
							MessageBox('warning','您没有上传文件的权限，无法继续操作！');
							}else{
							MessageBox('warning', '上传失败，文件过大或过多或格式错误！');
							}
						}
					}
			    },
			    'onError'        : function (event, ID, fileObj, errorObj) {
			        alert(errorObj.type + ' Error: ' + errorObj.info);
			    },
			    'onAllComplete'	 : function(event, data) {
			    	attachUploadifyAllComplete{$attach_uploadify_id}(upfilename);
			    }
			});
			
			
			$("#viewAttachDiv{$attach_uploadify_id} img").each(function() {
			    if($(this).width() > $(this).parent().width()) {
			    	$(this).width("100%");
				}
			});
			
				
		});
		
		
		//删除一个文件
		function attachUploadifyDelete{$attach_uploadify_id}(idval)
		{
			var idval = ('undefined'==typeof(idval) ? 0 : idval);
			if(idval > 0) 
			{
				$.post
				(
					'ajax.php?mod=uploadattach&code=delete_attach',
					{
						'id' : idval
					},
					function (r) 
					{				
						if(r.done)
						{
							$('#uploadAttachSpan_' + idval).remove();
							
                            var contentTextBox = $('#'+__CONTENTID__);
                            var content = contentTextBox.val();
                            var r = "[attach]"+idval+"[/attach]";
                            var n = content.split(r).length - 1;
                            for (var i = 0; i < n ; i++) {
                                content = content.replace(r,"");
                            }
                            contentTextBox.val(content);
                            
							if( ($.trim(($('#viewAttachDiv{$attach_uploadify_id}').html()))).length < 1 )
							{
								$('#viewAttachDiv{$attach_uploadify_id}').css('display', 'none');
								$('#insertAttachDiv{$attach_uploadify_id}').css('display', 'block');
							}
							
							if( 'undefined' != typeof(__ATTACH_IDS__[idval]) )
							{
								__ATTACH_IDS__[idval] = 0;
							}
						}
						else
						{
							if(r.msg)
							{
								MessageBox('warning', r.msg);
							}
						}
					},
					'json'
				);
			}
		}
		
		function attachUploadifySelectOnce{$attach_uploadify_id}()
		{
			$('#uploadingAttach{$attach_uploadify_id}').html("<img src='images/loading.gif'/>&nbsp;上传中，请稍候……");
		}
		
		function attachUploadifyComplete{$attach_uploadify_id}(idval, srcval, nameval)
		{
			var attachIdsCount = 0;
	    	$.each( __ATTACH_IDS__, function( k, v ) { if( v > 0 ) { attachIdsCount += 1; } } );
	    	if( attachIdsCount >= {$attach_uploadify_queue_size_limit} )
	    	{
	    		MessageBox('warning', '本次文件数量超过限制了');
	    		return false;
	    	}
			
			var idval = ('undefined' == typeof(idval) ? 0 : idval);
			var srcval = ('undefined' == typeof(srcval) ? 0 : srcval);
			var nameval = ('undefined' == typeof(nameval) ? '' : nameval);
			
			{if 'topic_publish'==$attach_uploadify_from}
				$('#viewAttachDiv{$attach_uploadify_id}').prepend('<li id="uploadAttachSpan_' + idval + '" class="menu_ps vv_2"><img src="' + srcval + '" class="uploadAttachSpan_img_type"/> <p class="uploadAttachSpan_doc_type"><i>' + nameval + '</i></p><p>（<a title="删除文件" onclick="attachUploadifyDelete{$attach_uploadify_id}(' + idval + ');return false;" href="javascript:;">删</a>）需<input title="填写用户下载该附件所需贡献给你的积分" size="1" type="text" onblur="set_attach_score(this.value,' + idval + ',this);return false;">积分 </p></li>');
			{elseif 'topic_longtext_info_ajax'==$attach_uploadify_from}			
				$('#viewAttachDiv{$attach_uploadify_id}').append('<span id="uploadAttachSpan_' + idval + '"><img src="' + srcval + '" width="{$attach_img_siz}" alt="点击文件插入到文中" onclick="longtext_info_img_insert(\'' + srcval + '\');" />（<a href="javascript:void(0);" onclick="attachUploadifyDelete{$attach_uploadify_id}(' + idval + '); return false;" title="删除文件">删</a>）需<input title="填写用户下载该附件所需贡献给你的积分" size="1" type="text" onblur="set_attach_score(this.value,' + idval + ',this);return false;">积分</span>');
			{else}
				$('#viewAttachDiv{$attach_uploadify_id}').append('<span id="uploadAttachSpan_' + idval + '"><img src="' + srcval + '" width="{$attach_img_siz}" />（<a href="javascript:void(0);" onclick="attachUploadifyDelete{$attach_uploadify_id}(' + idval + '); return false;" title="删除文件">删</a>）需<input title="填写用户下载该附件所需贡献给你的积分" size="1" type="text" onblur="set_attach_score(this.value,' + idval + ',this);return false;">积分</span>');
			{/if}
			
			$('#normalAttachUploadFile{$attach_uploadify_id}').val('');
			
			__ATTACH_IDS__[idval] = idval;
		}
		
		function attachUploadifyAllComplete{$attach_uploadify_id}(nameval)
		{
			var nameval = ('undefined' == typeof(nameval) ? '' : nameval);
			$('#uploadingAttach{$attach_uploadify_id}').html('');			    	
	    	$('#viewAttachDiv{$attach_uploadify_id}').css('display', 'block');
	    	//$('#insertAttachDiv{$attach_uploadify_id}').css('display', 'none');
	    	if( $.trim(($('#{$topic_textarea_id}').val())).length < 1 ) {
	    		$('#{$topic_textarea_id}').val('{$topic_textarea_empty_val}' + ':' + nameval);	
	    	}
	    	$('#{$topic_textarea_id}').focus();
		}
		
		function normalAttachUploadFormSubmit{$attach_uploadify_id}()
		{
			var fileVal = $('#normalAttachUploadFile{$attach_uploadify_id}').val();
			
			if(($.trim(fileVal)).length < 1)
			{
				MessageBox('warning', '请上传正确格式的附件文件');
				return false;
			}
			else
			{
				if(!(/\.(zip|rar|txt|doc|xls|pdf|ppt|docx|xlsx|pptx)$/i.test(fileVal)))
				{
					MessageBox('warning', '请选择一个正确格式的附件文件');
					return false;
				}
				else
				{
					attachUploadifySelectOnce{$attach_uploadify_id}();
					return true;
				}
			}
		}
		
		function attachUploadifyModuleSwitch{$attach_uploadify_id}()
		{
			if('none' == $('#normalAttachUploadDiv{$attach_uploadify_id}').css('display'))
			{
				$('#uploadDescModuleSpanAttach{$attach_uploadify_id}').html('快速');
				$('#swfUploadDivAttach{$attach_uploadify_id}').css('display', 'none');
				$('#normalAttachUploadDiv{$attach_uploadify_id}').css('display', 'block');
			}
			else
			{
				$('#uploadDescModuleSpanAttach{$attach_uploadify_id}').html('普通');
				$('#normalAttachUploadDiv{$attach_uploadify_id}').css('display', 'none');
				$('#swfUploadDivAttach{$attach_uploadify_id}').css('display', 'block');
			}
		}
		function modify_attach(id){var id = ('undefined'==typeof(id) ? 0 : id);var handle_key = 'mod_attach_win';var ajax_url = "ajax.php?mod=uploadattach&code=modify";showDialog(handle_key, 'ajax', "编辑", {"url":ajax_url, "post":{id:id}}, 400);}
		
		</script>
	   <!--{if !$attach_uploadify_only_js}-->
       <div id="insertAttachDiv{$attach_uploadify_id}" class="insertAttachDiv">
       <span class="arrow-up"></span>   
       <span class="arrow-up-in"></span>
       <i class="insertAttachDiv_up" onclick="$(this).parent().hide()"><img src="images/imgdel.gif" title="关闭" /></i>
       <div id="swfUploadDivAttach{$attach_uploadify_id}"><input type="file" id="publisher_file_attach{$attach_uploadify_id}" name="publisher_file{$attach_uploadify_id}" style="display:none;" /></div>
	   <iframe id="attachUploadifyIframe{$attach_uploadify_id}" name="attachUploadifyIframe{$attach_uploadify_id}" width="0" height="0" marginwidth="0" frameborder="0" src="about:blank" style="display:none;"></iframe>
	   <div id="normalAttachUploadDiv{$attach_uploadify_id}" style="display:none;">
	   <form id="normalAttachUploadForm{$attach_uploadify_id}" method="post" action="ajax.php?mod=uploadattach&code=attach&type=normal&aitem={$attach_item}&aitemid={$attach_itemid}&topic_uid={$attach_uploadify_topic_uid}" enctype="multipart/form-data" target="attachUploadifyIframe{$attach_uploadify_id}" onsubmit="return normalAttachUploadFormSubmit{$attach_uploadify_id}()">
		<input type="hidden" name="attach_uploadify_id" value="{$attach_uploadify_id}" />
		<input type="file" id="normalAttachUploadFile{$attach_uploadify_id}" name="topic" />
		<input type="submit" value="上传" class="tul" />
		</form>
		</div>
		<span id="uploadingAttach{$attach_uploadify_id}"></span>
		<div id="uploadDescDivAttach{$attach_uploadify_id}">
		<span class="fontRed">*</span> 如果您不能上传文件，可以<a href="javascript:;" onclick="attachUploadifyModuleSwitch{$attach_uploadify_id}();">点击这里</a>尝试<span id="uploadDescModuleSpanAttach{$attach_uploadify_id}">普通</span>模式上传
		{if 'topic_longtext_info_ajax'==$attach_uploadify_from}
		<br /><span class="fontRed">*</span> 文件上传成功后，可以点击文件将文件插入到您想要的位置
		{/if}
		</div>
        
        <div id="uploadifyQueueDivAttach{$attach_uploadify_id}" style="display:none;"></div>
        <div id="viewAttachDiv{$attach_uploadify_id}" class="viewAttachDiv">
        <!--{if (!$attach_uploadify_new || $attach_uploadify_modify) && $attach_uploadify_topic[attachid]}-->        	
        <!--{loop $attach_uploadify_topic[attach_list] $ik $iv}-->
        <script type="text/javascript"> __ATTACH_IDS__[{$ik}] = $ik; </script>
        <p id="uploadAttachSpan_{$ik}" style="padding: 5px 0;">
	    <img src="{$iv[attach_img]}" width="{$attach_img_siz}" id="atta_{$ik}" style="vertical-align: middle;"/>&nbsp;下载附件需消耗<input title="填写用户下载该附件所需贡献给你的积分" size="1" type="text" value="{$iv[attach_score]}" onblur="set_attach_score(this.value,{$iv[id]},this);return false;">积分&nbsp;&nbsp;<a href="javascript:void(0);" onclick="modify_attach({$iv[id]});return false;">编辑</a>&nbsp;&nbsp;<a href="javascript:void(0);" onclick="attachUploadifyDelete{$attach_uploadify_id}('$ik'); return false;" title="删除文件">删除</a>
	    </p>
        <!--{/loop}-->
        <!--{/if}-->
        </div>   
	    </div>
        <!--{/if}-->
        
 <style type="text/css">
 .vv_2{ width:190px; position:relative;}
 .vv_2{ width:190px; position:relative;}
 </style>
 